package com.inossem.warehousestorage_inossem.request.outStorage;

import android.content.Context;

import com.google.gson.Gson;
import com.inossem.warehousestorage_inossem.bean.outStorage.OutStorageSaleAddBatchBean;
import com.inossem.warehousestorage_inossem.bean.outStorage.OutStorageSaleAddBatchRequestBean;
import com.inossem.warehousestorage_inossem.constant.RequestConstant;
import com.inossem.warehousestorage_inossem.listener.GsonBeanListener;
import com.inossem.warehousestorage_inossem.listener.StringRequestListener;
import com.inossem.warehousestorage_inossem.manage.RequestManage;
import com.inossem.warehousestorage_inossem.model.StringResponse;
import com.inossem.warehousestorage_inossem.request.Request;

/**
 * Created by leij on 2017/6/12.
 */

public class OutStorageSaleAddBatchRequest extends Request {


    public static String request(Context context, String materielCode, String factoryCode, String inventoryAddressCode, GsonBeanListener gsonBeanListener) {
        String tag;
        OutStorageSaleAddBatchRequestBean outStorageSaleAddBatchRequestBean = new OutStorageSaleAddBatchRequestBean();
        outStorageSaleAddBatchRequestBean.setMat_id(materielCode);
        outStorageSaleAddBatchRequestBean.setFty_id(factoryCode);
        outStorageSaleAddBatchRequestBean.setLocation_id(inventoryAddressCode);
        outStorageSaleAddBatchRequestBean.setReceipt_type("42");
        Gson gson = new Gson();
        String json = gson.toJson(outStorageSaleAddBatchRequestBean, OutStorageSaleAddBatchRequestBean.class);
        String url = RequestManage.getUrl(context, RequestConstant.URL_OUT_STORAGE_SALE_ADD_BATCH);
        tag = RequestManage.getHttpsPostWithLoading(context, url, json, new StringRequestListener() {
            @Override
            public void onSuccess(StringResponse stringRequestResponse) {
                Gson gson = new Gson();
                OutStorageSaleAddBatchBean bean = gson.fromJson(stringRequestResponse.getResponseInfo(), OutStorageSaleAddBatchBean.class);
                excuteJsonBean(context, bean, bean.getHead().getError_code(), bean.getHead().getError_string(), gsonBeanListener);
            }
        });
        return tag;
    }

}
